package com.example.rae.zookeepe.rorder;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient
public class ZkOrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(ZkOrderApplication.class, args);
        // 如果使用rest别名的方式进行调用依赖ribbon负载均衡器@LoadBalanced
        // @LoadBalanced就能让这个RestTemplate在请求时拥有客户端负载均衡的能力
    }

    // 解决RestTemplate 找不到原因，应该把RestTemplete注册到SpringBoot容器中，@Bean
    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
